package com.ruoyi.system.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class LetterConsumer {

    @RabbitListener(queues = "letterQueueA")
    public void consumerQueueA(Message message, Channel channel) throws IOException {
        System.err.println("收到死信A消息:==============="+message.getBody()+"=================");
        //消息确认
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }

    @RabbitListener(queues = "letterQueueB")
    public void consumerQueueB(Message message, Channel channel) throws IOException {
        System.err.println("收到死信B消息:==============="+message.getBody()+"=================");
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
